package com.zpphis.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zpphis.entity.Disease;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author zpp
 * @since 2022-11-22
 */
@Mapper
public interface DiseaseMapper extends BaseMapper<Disease> {

    @Select("SELECT\n" +
            "\td.id,\n" +
            "\td.disease_code,\n" +
            "\td.disease_name,\n" +
            "\td.disease_icd,\n" +
            "\tdc.dica_name diseCategory\n" +
            "FROM\n" +
            "\tt_disease d\n" +
            "INNER JOIN t_dise_category dc ON dc.id = d.dise_category_id\n" +
            "WHERE\n" +
            "\td.del_mark = 1\n" +
            "AND (\n" +
            "\td.disease_code LIKE #{queryString}\n" +
            "\tOR d.disease_name LIKE #{queryString}\n" +
            "\tOR d.disease_icd LIKE #{queryString}\n" +
            "\tOR d.disease_icd LIKE #{queryString}\n" +
            "\tOR dc.dica_name LIKE #{queryString}\n" +
            ")")
    Page<Map<String, Object>> pageExtend(Page<Map<String, Object>> p, String queryString);
}
